<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page isELIgnored="false"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%@ page import="course.method"%>
<%@ page import="javax.swing.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>admin-System</title>
<link rel="stylesheet" href="<c:url value='css\index.css'></c:url>" />
<%-- <link rel="stylesheet" href="<c:url value='css\bootstrap.css'></c:url>" /> --%>
<link rel="stylesheet" href="<c:url value='css\bootstrap-v4.6.0.css'></c:url>" />
<link rel="stylesheet" href="<c:url value='css\user.css'></c:url>" />
<!-- <script src="./lib/echarts.js"></script>
<script src="./lib/jquery.js"></script>
<script src="./lib/axios.js"></script>
<script src="./lib/form-serialize.js"></script> -->
</head>
<body>
<%
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");
Connection con = null;
Statement sql;
ResultSet rs;
try{
Class.forName("com.mysql.cj.jdbc.Driver");
}
catch(Exception e){
out.print("<h1>"+e);
}
String url = "jdbc:mysql://localhost:3306/course?"+
"useSSL=false&serverTimezone=GMT&characterEncoding=utf-8";
String user = "root";
String password = "123456";
%>

<div>
<div class="back"></div>
<div class="containerback">
<div class="banner">
<div class="xiaohui"></div>
<div id="title"><p >长春工业大学图书管理系统</p></div>
<div id="quit">
<img id="quitimg" src="./imgs/退出.png">
<a id="quita" href="login.jsp">退出</a>
</div>
</div>
<!-- 工作区 -->
<div class="work">
<div class="work-left">
<div class="option slide">学生管理</div>
<div class="option">图书管理</div>
</div>
<!-- 学生信息管理 -->
<div class="work-right block">
<h1>新增学生</h1>
  <div class="info">
  <form action="Admin_add" method="post">
    学号：<input type="text" name="idnum">
    姓名：<input type="text" name="uname">
    密码：<input type="text" name="key">
    年龄：<input type="text" name="age">
    性别: <select name="sex" id="" class="sex">
      <option value="男">男</option>
      <option value="女">女</option>
    </select>
    电话：<input type="text" name="phone">
    所属学院：<select name="school" id="" class="school">
     <option selected value="">请选择所属学院</option>
                  <option value="机电工程学院">机电工程学院</option>
                  <option value="计算机科学与工程学院">计算机科学与工程学院</option>
                  <option value="化学与生命科学学院">化学与生命科学学院</option>
                  <option value="人文学院">人文学院</option>
                  <option value="外国语学院">外国语学院</option>
                  <option value="材料科学与工程学院">材料科学与工程学院</option>
                  <option value="经济管理学院">经济管理学院</option>
                  <option value="艺术设计学院">艺术设计学院</option>
                  <option value="应用技术学院">应用技术学院</option>
                  <option value="电器与电子工程学院">电器与电子工程学院</option>
                  <option value="化学工程学院">化学工程学院</option>
                  <option value="信息传播工程学院">信息传播工程学院</option>
                  <option value="数学与统计学院">数学与统计学院</option>
    </select>
    <button type="submit" class="add">录入</button>
    </form>
  </div>

  <h1>已录学生信息</h1>
  <table id="addstudent">
    <thead style="text-align:center">
      <tr>
        <th>学号</th>
        <th>姓名</th>
        <th>密码</th>
        <th>年龄</th>
        <th>性别</th>
        <th>电话</th>
        <th>所属学院</th>
        <th>操作</th>
      </tr>
    </thead>
    <tbody>
      <!-- <tr>
        <td>1001</td>
        <td>欧阳霸天</td>
        <td>123456</td>
        <td>22</td>
        <td>男</td>
        <td>13912341234</td>
        <td>经济管理学院</td>
        <td>
          <a href="javascript:">删除</a>
        </td>
      </tr> -->
       <%
             int j = 0;
             try{
            	 con=DriverManager.getConnection(url,user,password);
            	 sql = con.createStatement();
            	 String selectSQL="select*from studentinfo";	

            	 rs=sql.executeQuery(selectSQL);
            	 while(rs.next()){
            		 out.print("<tr>");
 	    		    out.print("<td>"+rs.getString(1)+"</td>");
 	    		    out.print("<td>"+rs.getString(2)+"</td>");
 	    		    out.print("<td>"+rs.getString(3)+"</td>");
 	    		    out.print("<td>"+rs.getString(4)+"</td>");
 	    		    out.print("<td>"+rs.getString(6)+"</td>");
 	    		    out.print("<td>"+rs.getString(7)+"</td>");
 	    		    out.print("<td>"+rs.getString(5)+"</td>");
 	    		    /* out.print("<td><button type="+"button"+" style="+"color:white"+" class="+"btn btn-link btn-sm btn-del"+" data-id="+j+++">借阅</button></td>"); */
 	    		    out.print("<td><a data-id="+j+++" href=\"javascript:\">删除</a></td>");
 	    		    out.print("<form action ="+ "Admin_delete"+" method=post>");
 	    		    out.print("<input name=number type=hidden value="+rs.getString(1)+">");
 	    		    out.print("<input hidden type=submit name=delete value=删除数据>");
 	    		    out.print("</form>");
 	    		    out.print("</tr>");
            	 }
            	 con.close();
            	 }
            	 catch(SQLException e){
            	 out.print("<h1>"+e);
            	 }                
             %> 
      
      
    </tbody>
  </table>
</div>

<!-- 图书信息管理 -->
<div class="work-right">
  <h1>新增图书</h1>
  <div class="info">
  <form action="Book_add" method="post">
    ISBN：<input type="text" name="isbn">
    书名：<input type="text" name="bookname">
    作者：<input type="text" name="writer">
    出版社：<input type="text" name="publisher">
    库存量：<input type="text" name="store">
    <button type="submit" class="add">录入</button>
    </form>
  </div>

  <h1>已录图书信息</h1>
  <table id="addbook">
    <thead style="text-align:center">
      <tr>
        <th>ISBN</th>
        <th>书名</th>
        <th>作者</th>
        <th>出版社</th>
        <th>库存量</th>
        <th>操作</th>
      </tr>
    </thead>
    <tbody>
      <!-- <tr>
        <td>1001</td>
        <td>欧阳霸天</td>
        <td>123456</td>
        <td>22</td>
        <td>男</td>
        <td>13912341234</td>
        <td>经济管理学院</td>
        <td>
          <a href="javascript:">删除</a>
        </td>
      </tr> -->
       <%
             int i = 0;
             try{
            	 con=DriverManager.getConnection(url,user,password);
            	 sql = con.createStatement();
            	 String selectSQL="select*from booklist";	

            	 rs=sql.executeQuery(selectSQL);
            	 while(rs.next()){
            		 out.print("<tr>");
 	    		    out.print("<td>"+rs.getString(1)+"</td>");
 	    		    out.print("<td>"+rs.getString(2)+"</td>");
 	    		    out.print("<td>"+rs.getString(3)+"</td>");
 	    		    out.print("<td>"+rs.getString(4)+"</td>");
 	    		    out.print("<td>"+rs.getString(5)+"</td>");
 	    		    /* out.print("<td><button type="+"button"+" style="+"color:white"+" class="+"btn btn-link btn-sm btn-del"+" data-id="+j+++">借阅</button></td>"); */
 	    		    out.print("<td><a data-id="+i+++" href=\"javascript:\">下架</a></td>");
 	    		    out.print("<form action ="+ "Book_delete"+" method=post>");
 	    		    out.print("<input name=number type=hidden value="+rs.getString(1)+">");
 	    		    out.print("<input hidden type=submit name=del value=删除数据>");
 	    		    out.print("</form>");
 	    		    out.print("</tr>");
            	 }
            	 con.close();
            	 }
            	 catch(SQLException e){
            	 out.print("<h1>"+e);
            	 }                
             %> 
      
      
    </tbody>
  </table>
</div>
</div>
</div>
</div>
<!-- <script type="module" src="./js/seat.js"></script> -->
<!-- <script src="./js/echarts.js"></script> -->
<!-- <script src="./js/seat.js"></script>
<script src="./js/province.js"></script> -->
<script src="./js/admin.js"></script>
</body>
</html>